#include "trueending.h"
#include "ui_trueending.h"
#include <QPainter>
#include <QFont>
#include <QPixmap>
#include <QTimer>

int iending=1;

trueending::trueending(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::trueending)
{
    ui->setupUi(this);
    this->setAttribute(Qt::WA_DeleteOnClose);
}

void trueending::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setPen(Qt::black);//设置画笔颜色
    painter.setBrush(Qt::black);//设置填充颜色
    painter.drawRect(0,0,500,480);
    int x1=ui->qhframe->pos().x();
    int y1=ui->qhframe->pos().y();
    qh[0].load(":/resourse/0.png") ;
    qh[1].load(":/resourse/1.png") ;
    qh[2].load(":/resourse/2.png") ;
    qh[3].load(":/resourse/3.png") ;
    qh[4].load(":/resourse/4.png") ;
    qh[5].load(":/resourse/5.png") ;
    qh[6].load(":/resourse/6.png") ;
    qh[7].load(":/resourse/7.png") ;
    qh[8].load(":/resourse/8.png") ;
    qh[9].load(":/resourse/9.png") ;
    qh[10].load(":/resourse/10.png") ;
    qh[12].load(":/resourse/12.png") ;
    qh[13].load(":/resourse/13.png") ;
    qh[14].load(":/resourse/14.png") ;
    QFont font1("Courier New",12);
    painter.setFont(font1);
    painter.setPen(Qt::red);
    painter.setBrush(Qt::red);
    painter.drawText(20,185,dialog[iending]);

    if (iending==5)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[14]);
    }

    if (iending==6||iending==7)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[1]);
    }
    if (iending==8)
    {
        iending=1;
        this->close();
        game *g =new game();
        g->show();
    }

}

void trueending::on_nextpushButton_clicked()
{
    iending++;
    update();
}

trueending::~trueending()
{
    delete ui;
}
